// pages/login/login.js
var utlis = require("../../utils/network.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
  username:'',
  password:'',
  isLogin:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
    this.setData({
      isLogin: true
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  loginButton: function(){
    console.log('QQQQQQQQQQQQQQQQQQQQQ')
    if (this.data.username == "") {
      wx.showToast({
        title: '请输入手机号',
        icon: 'none',
        duration: 1000
      })

      return;
    }

    if (this.data.username.length!=11) {
      wx.showToast({
        title: '请输入11位手机号',
        icon: 'none',
        duration: 1000
      })

      return;
    }

    if (this.data.password == "") {
      wx.showToast({
        title: '请输入密码',
        icon: 'none',
        duration: 1000
      })

      return;
    }

    console.log('AAAAAAAAAAAAAAAAAAA')
    var json = { "CurrentCity": "", "LoginType": "0", "OfflinePINToken": "", "Password": "e10adc3949ba59abbe56e057f20f883e", "SEID": "", "SubmitTime": "20180223140105", "UserName": "18785092860", "imei": "863539032308499", "incode": "0000", "ip": "222.85.161.58", "phoneModel": "HUAWEI  KNT-AL10", "phoneType": 0, "systemVersion": "V1.2.0", "userPhone": "18785092860", "uuid": "1B16967C88160AD6C02835AB6305D216" }
    utlis.requestLoading( "https://www.gztpay.com:65067/appserver/user/login", json, "登录中...", function (res) {
      //res就是我们请求接口返回的数据
      console.log(res)
    }, function () {
      wx.showToast({
        title: '加载数据失败',
      })
    })

  },

  usernameKeyInput: function(e){
    this.setData({
    username: e.detail.value
  })
  } ,

  passKeyInput: function(e){
    this.setData({
      password: e.detail.value
    })
  }


})